﻿using Microsoft.CSharp.Activities;
using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Returns detailed information about the relationship between two arbitrary users.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.RelationshipToolbox.bmp")]
    [Designer(typeof(RelationshipDesigner))]
    [Description("Returns detailed information about the relationship between two arbitrary users.")]
    public class GetFriendships : TwitterOperationInvoker<RelationshipResult>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetFriendships"/> class.
        /// </summary>
        public GetFriendships()
            : base("GetFriendships")
        { }

        /// <summary>
        /// The screen_name of the subject user.
        /// </summary>
        /// <value>
        /// The source username.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [RequiredArgument]
        [Description("The screen_name of the subject user.")]
        public InArgument<string> SourceUsername { get; set; }

        /// <summary>
        ///The screen_name of the target user.
        /// </summary>
        /// <value>
        /// The target username.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [RequiredArgument]
        [Description("The screen_name of the target user.")]
        public InArgument<string> TargetUsername { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument sourceUsernameArgument = new RuntimeArgument("SourceUsername", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(SourceUsername, sourceUsernameArgument);
            metadata.AddArgument(sourceUsernameArgument);

            RuntimeArgument targetUsernameArgument = new RuntimeArgument("TargetUsername", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(TargetUsername, targetUsernameArgument);
            metadata.AddArgument(targetUsernameArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("sourceUsername", SourceUsername);
            Parameters.Add("targetUsername", TargetUsername);

            base.Execute(context);
        }
    }
}
